<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>用户列表</title>
    <link rel="stylesheet" th:href="@{/css/style.css}">
</head>
<body>
    <div class="container">
        <h1>用户列表</h1>
        
        <a th:href="@{/users/new}" class="btn btn-primary">新建用户</a>
        
        <table class="table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>姓名</th>
                    <th>邮箱</th>
                    <th>手机号</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="user : ${users}">
                    <td th:text="${user.id}"></td>
                    <td th:text="${user.name}"></td>
                    <td th:text="${user.email}"></td>
                    <td th:text="${user.phone}"></td>
                    <td th:text="${user.gender?.displayName}"></td>
                    <td th:text="${user.birthDate != null ? #temporals.year(#temporals.createNow()) - #temporals.year(user.birthDate) : ''}"></td>
                    <td class="action-links">
                        <a th:href="@{/users/{id}/edit(id=${user.id})}">编辑</a>
                        <form th:action="@{/users/{id}/delete(id=${user.id})}" 
                              method="post" 
                              style="display: inline;"
                              onsubmit="return confirm('确定要删除这个用户吗？');">
                            <button type="submit" class="btn-link">删除</button>
                        </form>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html> 